/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-03-05
 * Time:9:01
 */
import java.util.Scanner;
//最大公因数
class num{
    private int a;
    private int b;
    private int i;
    num(int a,int b)
    {
        this.a=a;
        this.b=b;
    }
    public void setmax()
    {
        this.i=a%b;
        while(i!=0)
        {
           a=b;
           b=this.i;
           this.i=a%b;
        }
        this.i=b;
    }
    public int getmax()
    {
        return i;
    }

}
//二进数1的个数
class Text1{
    private int num;
    private int nums;
    public int getNum() {
        return num;
    }

    public void setNum(int kk) {
       while(kk!=0)
       {
           if((kk&1)!=0)
           {
               num++;
           }
           kk=kk>>>1;
       }
    }
    public int getNums() {
        return nums;
    }

    public void setNums(int kk) {
        while(kk!=0)
        {
            kk=kk&(kk-1);
                nums++;
        }
    }
}
//判断奇偶数
class oddNumber{
      private int c;
      String Number;
      oddNumber(int d)
      {
          c=d;
      }
      public void numbers()
      {
         int i=32;
          System.out.println("偶数位： ");

         for(i=31;i>=0;i-=2)
         {
             System.out.print("  "+(c>>i&1));
         }
          System.out.println("\n奇数位:");
         System.out.print(" ");
          for(i=30;i>=0;i-=2)
          {
              System.out.print("  "+(c>>i&1));
          }

      }
    }
    //输出一个数的每一位
class Text2{
    private int c;
    Text2()
    {}
     public static  void  getnum(int k)
    {
        if(k>9)
        {
            getnum(k/10);
        }
        System.out.print(k%10+" ");
    }

    }
    //模拟登录
class mm{
    private String mimi;
    mm(String mm)
    {
        this.mimi=mm;
    }
    public boolean judgePassword(String mm)
    {
       if (mm.equals(mimi))
        return true;
       else
        return false;
    }
 }
public class Text {
    public static void main(String[] args) {
        System.out.println("--------公因数---------");
        num fw =new num(64,32);
        fw.setmax();
        System.out.println(fw.getmax());
        System.out.println("---------二进制个数---------");
        Text1 k=new Text1();
        k.setNums(9);
        System.out.println(k.getNums());
        System.out.println("----------奇偶数位------");
        oddNumber cc=new oddNumber(8);
        cc.numbers();
        System.out.println("\n---------输出每一位---------");
        int a=0;
        Scanner sc=new Scanner(System.in);
        a=sc.nextInt();
        Text2 s=new Text2();
        s.getnum(a);
        System.out.println("\n---------输出密码----------");
        mm ct =new mm("我是汤琦");
        int i=3;
        String mama=sc.next();
        while(i>0)
        {
            if(ct.judgePassword(mama)) {
                System.out.println("密码正确");
                break;
            }
            System.out.println("输入错误还有"+i+"次机会\n重新输入密码：");
            mama=sc.next();
            i--;
        }
        System.out.println("冻结账户");
    }
}
